package thermologic.file;

import java.io.File;
import javax.swing.filechooser.FileFilter;

/**
 * @author mrivadeneira
 */
public class FileFilterImpl extends FileFilter
{
    public static final String EXTENSION = ".tlg";
    public static final String EXCEL_EXTENSION = ".xls";
    public static final String XML_EXTENSION = ".xml";
    
    private String extension;
    
    public FileFilterImpl(String ext)
    {
        setExtension(ext);
    }

    public FileFilterImpl() {
        this(EXTENSION);
    }

    public String getExtension() {
        return extension;
    }

    public void setExtension(String extension) {
        this.extension = extension;
    }
    
    
    
    public String getDescription() {
        return java.util.ResourceBundle.getBundle("properties/language").
                getString("thermologic.openfile.filedescription");
    }
    
    public boolean accept(File file){

        boolean ret = false;

        if(file.isDirectory())
        {
            ret = true;
        }
        else if(file.getName().endsWith(getExtension()))
        {
            ret = true;
        }
        return ret;
    }
    
}
